<template>
    <el-card shadow="never" style="border: 0;">
        <el-table :data="list">
            <el-table-column  prop="name" label="名称">
                <template #default="{row}">
                   <el-input v-model="row.name"></el-input>
                </template>
            </el-table-column>
            <el-table-column  prop="price" label="价格（元）">
                <template #default="{row}">
                   <el-input v-model="row.price"></el-input>
                </template>
            </el-table-column>
            <el-table-column  prop="unit" label="单位">
                <template #default="{row}">
                   <el-input v-model="row.unit"></el-input>
                </template>
            </el-table-column>
            <el-table-column  label="删除" width="120">
                <template #default="scope">
                    <el-button type="danger" size="small" @click="list.splice(scope.$index,1)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div style="position: absolute;bottom: 10px;left: 10px;">
            <el-button type="primary" @click="addSpec"><i class="fa fa-plus"></i>&nbsp;增加规格</el-button>
            <el-button type="success" @click="confirmSpec"><i class="fa fa-check"></i>&nbsp;确认修改</el-button>
        </div>
    </el-card>
</template>
<script>
    export default{
        data:{
            goods_id:'',
            list:Yunqi.data.list || []
        },
        onLoad:function(e){
            this.goods_id = e.goods_id;
        },
        methods: {
            addSpec:function(){
                this.list.push({name:'',price:'',unit:''});
            },
            confirmSpec:function(){
                Yunqi.ajax.json('delivery/goods/setSpec?goods_id='+this.goods_id,this.list,true,true).then(res=>{
                    Yunqi.api.closelayer();
                });
            }
        }
    }
</script>
<style>
    
</style>

